package com.dm.cloud.images.mode;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

import java.util.LinkedHashMap;
import java.util.List;

@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@Schema(description ="应用基本信息")
@Data
public class AppInfoModel {

    @Schema(description = "容器总量")
    private int containerSize=0;

    @Schema(description = "容器状态,目前支持5种：created（已创建），running（运行中），paused（暂停），exited（停止），dead（死亡）")
    private LinkedHashMap<String,Integer> containerStatus=new LinkedHashMap<String,Integer>(){{
        put("created",0);
        put("running",0);
        put("paused",0);
        put("exited",0);
        put("dead",0);
    }};

    @Schema(description = "相关节点总量")
    private int nodeSize;

    @Schema(description = "正在运行节点数量")
    private int activateNodeSize;

    @Schema(description = "异常节点数量")
    private int errNodeSize;

    @Schema(description = "节点容器详情")
    private List<AppNodeInfoModel> nodeInfos;

    public void addActivateNodeSize(int i){
        this.activateNodeSize+=i;
    }

    public void addErrNodeSize(int i){
        this.errNodeSize+=i;
    }
    /**
     * 添加容器状态统计
     * @param status
     * @param i
     */
    public void addStatus(String status, int i) {
        if(containerStatus.containsKey(status)){
            int x=containerStatus.get(status);
            containerStatus.put(status,x+i);
        }else{
            containerStatus.put(status,i);
        }
    }
}
